package com.company;

import java.util.HashSet;
import java.util.Set;

/**
 * @author lichengcheng
 * @date 2021/9/30
 */
public class lengthOfLongestSubstring {
    public int lengthOfLongestSubstringaa(String s) {
        Set<Character> str = new HashSet<Character>();  //设置哈希集合，记录每个字符是否出现过；
        int n = s.length();
        int maxlen = 0;
        int j = 0;
        for (int i = 0; i < n; i++){
            for (j = i+1;j < n; j++){
                if (!str.contains(s.charAt(i))) {    //判断集合里面是否有重复的字符；
                    str.add(s.charAt(j));      //指针右移
                }
            }
            maxlen = Math.max(maxlen,j-i-1);
        }
        return maxlen;
    }

    public static void main(String[] args) {
        String s = "abcabcbb";
    }
}
